package com.ffcs.cn.action.desktopcontrol.smcheckboxtristate;

import com.supermap.desktop.controls.ui.SmCheckBoxTristate;
import com.supermap.desktop.controls.ui.controls.SmDialog;
import com.supermap.desktop.core.Application;

import java.awt.*;

/**
 * 多状态的复选框的示例对话框
 *
  */
public class DialogSmCheckBoxTristate extends SmDialog {
	private SmCheckBoxTristate smCheckBoxTristate;

	public DialogSmCheckBoxTristate() {
		setTitle("多状态的复选框");
		setSize(new Dimension(300, 100));
		initComponents();
		initLayout();
	}

	private void initComponents() {
		smCheckBoxTristate = new SmCheckBoxTristate("多状态复选框");
		// 根据选择状态的不同，输出不同信息
		smCheckBoxTristate.addStateChangeListener(e -> {
			if (e.getState().equals(SmCheckBoxTristate.SELECTED)) {
				Application.getActiveApplication().getOutput().output("选中了");
			} else if (e.getState().equals(SmCheckBoxTristate.NOT_SELECTED)) {
				Application.getActiveApplication().getOutput().output("未选中");
			} else if (e.getState().equals(SmCheckBoxTristate.DONT_CARE)) {
				Application.getActiveApplication().getOutput().output("无状态");
			}
		});
	}

	private void initLayout() {
		this.add(smCheckBoxTristate);
	}
}
